﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Mod_FlatManger_frm_UpdateUserPwd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            string strOldPwd = this.txtOldPwd.Text.Trim();
            string strNewPwd = this.txtNewPwd2.Text.Trim();

            ClsUserLoginDAL cls_UserLogin = new ClsUserLoginDAL();
            int intCount = cls_UserLogin.SysUserLogin(strUserID, strOldPwd, "", "", 1);

            if (intCount > 0)
            {
                Boolean is_Succeed = cls_UserLogin.UpdateUserPwd(strUserID, strNewPwd);

                if (is_Succeed)
                {
                    this.lblJs.Text = "<script>alert('修改密码成功！');window.close();</script>";
                }
                else
                {
                    this.lblJs.Text = "<script>alert('修改密码失败，请重试！')</script>";
                }
            }
            else if (intCount == 0)
            {
                this.lblJs.Text = "<script>alert('原密码错误！')</script>";
            }
            else
            {
                this.lblJs.Text = "<script>alert('修改密码失败，请重试！')</script>";
            }
        }
        else
        {
            this.lblJs.Text = "<script>alert('用户信息丢失，请重新登录！');window.close();</script>";
        }
    }
}
